#include "qwtcompasshost.h"

#include "../../libs/qwt/qwt_compass.h"
#include "../../libs/shared/qhostfactory.h"
#include "../../libs/shared/qpropertyfactory.h"
#include "../../libs/shared/qcommonstruct.h"
#include "../../libs/shared/property/qabstractproperty.h"
#include "../../libs/qwt/qwt_dial_needle.h"

QwtCompassHost::QwtCompassHost(QAbstractHost *parent):
    QwtDialHost(parent)
{
}

void QwtCompassHost::init_property()
{
    QwtDialHost::init_property();


    remove_property("value");
    remove_property("totalSteps");
    remove_property("singleSteps");
    remove_property("pageSteps");
    remove_property("stepAlignment");
    remove_property("readOnly");
    remove_property("tracking");
    remove_property("wrapping");
    remove_property("invertedControls");
    remove_property("mode");
    remove_property("minScaleArc");
    remove_property("maxScaleArc");
    remove_property("lowerBound");
    remove_property("upperBound");
    remove_property("scaleMaxMajor");
    remove_property("scaleMaxMinor");
    remove_property("scaleStepSize");
    remove_property("needle_info");

    QAbstractProperty* pro;

    pro=QPropertyFactory::create_property("Enum");
    if(pro!=NULL)
    {
        pro->set_property("name","handleType");
        pro->set_attribute("show_name",tr("Needle Style"));
        pro->set_attribute("group","Attributes");

        ComboItems   items;
        tagComboItem item;

        item.m_text="Triangle";
        item.m_value=QwtCompassMagnetNeedle::TriangleStyle;
        items.append(item);

        item.m_text="Thin";
        item.m_value=QwtCompassMagnetNeedle::ThinStyle;
        items.append(item);

        pro->set_attribute("items",QVariant::fromValue<ComboItems>(items));
        pro->set_attribute(ATTR_CAN_SAME,true);
        insert_property(pro);
    }

    pro=QPropertyFactory::create_property("Color");
    if(pro!=NULL)
    {
        pro->set_property("name","light_color");
        pro->set_attribute("show_name",tr("Color 1"));
        pro->set_attribute("group","Attributes");
        pro->set_attribute(ATTR_CAN_SAME,true);
        pro->setProperty("color",true);
        insert_property(pro);
    }

    pro=QPropertyFactory::create_property("Color");
    if(pro!=NULL)
    {
        pro->set_property("name","dark_color");
        pro->set_attribute("show_name",tr("Color 2"));
        pro->set_attribute("group","Attributes");
        pro->set_attribute(ATTR_CAN_SAME,true);
        pro->setProperty("color",true);
        insert_property(pro);
    }

    set_property_value("geometry",QRect(0,0,100,100));
}

QString QwtCompassHost::get_show_name()
{
    return tr("QWT Compass");
}

QString QwtCompassHost::get_show_group()
{
    return tr("QWT Widgets");
}

QString QwtCompassHost::get_show_icon()
{
    return ":/images/icon_compass_alt.png";
}

void QwtCompassHost::create_object()
{
    m_object=new QwtCompass;
    m_object->setObjectName("compass");
}

qRegisterHost("qwt.compass",QwtCompassHost,6050)
